package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.kaishengit.entity.Admin;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class adminDao {
	private DBHelp<Admin> db=new DBHelp<Admin>();
	
	public Admin findByName(String name){
		String sql="select id, name,pwd from t_admin where name=?";
		return db.executeQueryForObject(sql, new AdminRowMapper(), name);
	}
	
	
	private class AdminRowMapper implements RowMapper<Admin>{

		public Admin mapRow(ResultSet rs) throws SQLException {
			Admin admin=new Admin();
			admin.setId(rs.getString("id"));
			admin.setName(rs.getString("name"));
			admin.setPassword(rs.getString("pwd"));
			return admin;
		}
		
	}
}
